﻿using RpcStore.Collect.LocalEvent.Model;
using RpcStore.DAL;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;

namespace RpcStore.Collect.LocalEvent
{
    [LocalEventName("Delete")]
    internal class DeleteTransmitSchemeEvent : IEventHandler<DeleteTransmitScheme>
    {
        private readonly IServerTransmitConfigDAL _BasicDAL;

        public DeleteTransmitSchemeEvent (IServerTransmitConfigDAL basicDAL)
        {
            this._BasicDAL = basicDAL;
        }

        public void HandleEvent (DeleteTransmitScheme data, string eventName)
        {
            if (data.Scheme.IsAuto)
            {
                return;
            }
            this._BasicDAL.Clear(data.Scheme.Id);
        }
    }
}
